{% extends './layout/default' %}

{% block breadcrumbs %}
    {{ Breadcrumbs.render(Route.getCurrentRoute.getName) }}
{% endblock %}

{% block content %}
    {% if piggyBanks|length == 0 %}
        {% include 'partials.empty' with {objectType: 'default', type: 'piggies',route: route('piggy-banks.create')} %}
    {% else %}
<div class="row">
    <div class="col-lg-12 col-md-12 col-sm-12">
        <div class="box">
            <div class="box-header with-border">
                <h3 class="box-title">{{ 'piggyBanks'|_ }}</h3>
            </div>
            <div class="box-body no-padding">
                <div style="padding:8px;">
                    <a class="btn btn-success" href="{{ route('piggy-banks.create') }}"><span class="fa fa-plus fa-fw"></span> {{ 'create_new_piggy_bank'|_ }}</a>
                </div>
                {% include 'list/piggy-banks' %}
            </div>
            <div class="box-footer">
                <a class="btn btn-success" href="{{ route('piggy-banks.create') }}"><span class="fa fa-plus fa-fw"></span> {{ 'create_new_piggy_bank'|_ }}</a>
            </div>
        </div>
    </div>
</div>

<div class="row">
    <div class="col-lg-12 col-md-12 col-sm-12">
        <div class="box">
            <div class="box-header with-border">
                <h3 class="box-title">{{ 'account_status'|_ }}</h3>
            </div>
            <div class="box-body no-padding">
                <table class="table table-responsive table-hover" id="accountStatus">
                    <thead>
                    <tr>
                        <th>{{ 'account'|_ }}</th>
                        <th style="text-align:right;" class="hidden-sm hidden-xs">{{ 'balance'|_ }}</th>
                        <th style="text-align:right;">{{ 'left_for_piggy_banks'|_ }}</th>
                        <th style="text-align:right;" class="hidden-sm hidden-xs">{{ 'sum_of_piggy_banks'|_ }}</th>
                        <th style="text-align:right;" class="hidden-sm hidden-xs">{{ 'saved_so_far'|_ }}</th>
                        <th style="text-align:right;" class="hidden-sm hidden-xs">{{ 'left_to_save'|_ }}</th>
                    </tr>
                    </thead>
                    <tbody>
                    {% for id,info in accounts %}
                        <tr>
                            <td><a href="{{ route('accounts.show',id) }}" title="{{ info.name }}">{{ info.name }}</a></td>
                            <td style="text-align:right;" class="hidden-sm hidden-xs">
                                {{ formatAmountBySymbol(info.current_balance,info.currency_symbol,info.currency_decimal_places) }}
                                </td>
                            <td style="text-align:right;">
                                {{ formatAmountBySymbol(info.left,info.currency_symbol,info.currency_decimal_places) }}
                            </td>
                            <td style="text-align:right;" class="hidden-sm hidden-xs">
                                {{ formatAmountBySymbol(info.target,info.currency_symbol,info.currency_decimal_places) }}
                            </td>
                            <td style="text-align:right;" class="hidden-sm hidden-xs">
                                {{ formatAmountBySymbol(info.saved,info.currency_symbol,info.currency_decimal_places) }}
                                </td>
                            <td style="text-align:right;" class="hidden-sm hidden-xs">
                                {{ formatAmountBySymbol(info.to_save,info.currency_symbol,info.currency_decimal_places) }}
                            </td>
                        </tr>
                    {% endfor %}
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
{% endif %}
{% endblock %}
{% block scripts %}
    <script src="v1/js/lib/jquery-ui.min.js?v={{ FF_VERSION }}" type="text/javascript" nonce="{{ JS_NONCE }}"></script>
    <script type="text/javascript" src="v1/js/ff/piggy-banks/index.js?v={{ FF_VERSION }}" nonce="{{ JS_NONCE }}"></script>
{% endblock %}
